package com.machine.filling.function.main.fuelingFg;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.machine.filling.R;
import com.machine.filling.function.main.base.BaseFgFragment;
import com.machine.filling.net.serialPort.receive.Receive_MachineState;
import com.machine.filling.util.HexUtils;

/**
 * Created by Administrator on 2018/2/1 0001.
 * 加油中界面
 */

public class FuelingFgFragment extends BaseFgFragment<FuelingFgContract.Presenter> implements FuelingFgContract.View {

    private TextView tv_oil_type;//油品
    private TextView tv_money;//金额
    private TextView tv_volume;//升数

    @Override
    public View initViews() {
        View view = LayoutInflater.from(mActivity).inflate(R.layout.fg_fg_fueling, null);
        tv_oil_type = view.findViewById(R.id.tv_oil_type);
        tv_money = view.findViewById(R.id.tv_money);
        tv_volume = view.findViewById(R.id.tv_volume);

        return view;

    }

    @Override
    public void initDatas() {

    }

    /**
     * 更新ui数据
     *
     * @param oilTypeName
     * @param cmd_state
     */
    public void updateUIDatas(String oilTypeName, Receive_MachineState cmd_state) {
        tv_oil_type.setText(oilTypeName);
        tv_money.setText(HexUtils.formatDouble(HexUtils.hex2Int(cmd_state.getFuel_amountStr()) * 0.01,2) + "元");
        tv_volume.setText(HexUtils.formatDouble(HexUtils.hex2Int(cmd_state.getFuel_quantityStr()) * 0.01,2) + "升");

    }
}
